
<?php
$model = new BDynamicFormModel();
$timeSlotUnitField = 'media_timeSlotUnit_analyse_interval_frequency';
$timeSlotCountField = 'media_timeSlotCount_analyse_interval_frequency';
$endTimeField = 'media_endTime_analyse_interval_frequency';
$operatorField = 'media_operator_analyse_interval_frequency';
$countOptionField = 'media_countOption_analyse_interval_frequency';
$model->addField($timeSlotUnitField);
$model->addField($timeSlotCountField);
$model->addField($endTimeField);
$model->addField($operatorField);
$model->addField($countOptionField);


?>
<div class="well">
    <div class="control-group">
        <label for="timeSlotUnit">时间：</label>
        <?php echo CHtml::activeDropDownList($model, $timeSlotUnitField, array('day' => '天', 'hour' => '小时', 'week' => '星期'), array('id' => 'timeSlotUnit', 'class' => 'span2')); ?>
        <?php echo CHtml::activeTextField($model, $timeSlotCountField, array('class' => 'span3', 'placeholder' => '时间单位次数')); ?>
        <?php echo CHtml::activeTextField($model, $endTimeField, array('class' => 'span4', 'placeholder' => '结束时间，［yyyymmdd］')); //这里加上时间输入控件 ?>
        <?php
        echo $control->getAjaxLink('分析', array(
            'cooker' => 'BCafeBill@showBillAnalyseIntervalFrequency',
            'htmlOptions' => array('class' => 'btn btn-primary')
        ));
        ?>
        <a href="#" rel="tooltip" title="
           ｛时间单位：用来统计回访时间间隔的时间单位｝
           ｛时间长度：指定统计的时间长度，这个数字乘以时间单位就是统计区间的时间长度｝
           ｛结束时间：可以不用指定，默认是从当前时间往前统计.｝" >说明</a>

    </div>
    <div class="control-group">
        <?php if (isset($analyseData) && $analyseData['countOptions']== 100) { ?>
            <label for = "operator">频率范围：</label>
            <?php
            echo CHtml::activeDropDownList($model, $operatorField, array('>' => '大于', '<' => '小于'), array('id' => 'operator', 'class' => 'span1'));
            echo CHtml::activeDropDownList($model, $countOptionField, $analyseData['countOptions'], array('class' => 'span2'));
            ?>
        <?php } ?>
    </div>
</div>
<ul class="breadcrumb">
    <li class="active">
        <?PHP
        echo $control->getAjaxLink(
                '最近24小时统计', array('cooker' => 'BCafeBill@showBillAnalyseIntervalFrequency',
            'period' => '24hours'));
        ?> <span class="divider">｜</span>
    </li>
    <li>
        <?PHP
        echo $control->getAjaxLink(
                '最近10天统计', array('cooker' => 'BCafeBill@showBillAnalyseIntervalFrequency',
            'period' => '10days'));
        ?><span class="divider">｜</span> 
    </li>
    <li>
        <?PHP
        echo $control->getAjaxLink(
                '最近20天统计', array('cooker' => 'BCafeBill@showBillAnalyseIntervalFrequency',
            'period' => '20days'));
        ?><span class="divider">｜</span> 
    </li>
    <li>
        <?PHP
        echo $control->getAjaxLink(
                '最近6个星期统计', array('cooker' => 'BCafeBill@showBillAnalyseIntervalFrequency',
            'period' => '6weeks'));
        ?><span class="divider">｜</span> 
    </li>
    <li>
        <?PHP
        echo $control->getAjaxLink(
                '最近6个月统计', array('cooker' => 'BCafeBill@showBillAnalyseIntervalFrequency',
            'period' => '6months'));
        ?>
    </li>
</ul>
<?php if (!isset($analyseData) || $analyseData['xData'] == NULL) { ?>
    <div class="well-small">
        <h5 class="text-error">没有数据，请检查设置是否正确！</h5>
    </div>
<?php } else { ?>
    <div>
        <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl . '/js/mobile/Chart.min.js' ?>"></script>
        <p><?php echo $analyseData['chartTitle']; ?></p>
        <p style="margin-top: 60px;float: left;width: 20px;"><?php echo $analyseData['y_axis']; ?></p>
        <canvas id="chart-line-2" width="300" height="200"></canvas>
        <p style="margin-left: 150px;"><?php echo $analyseData['x_axis']; ?> </p>
        <script>
            var data = {
                labels: [
    <?php
    $xData = $analyseData['xData'];
    foreach ($xData as $period) {
        echo '"' . $period . '",';
    }
    ?>
                ],
                datasets: [
                    {
                        label: "My Second dataset",
                        fillColor: "rgba(151,187,205,0.2)",
                        strokeColor: "rgba(151,187,205,1)",
                        pointColor: "rgba(151,187,205,1)",
                        pointStrokeColor: "#fff",
                        pointHighlightFill: "#fff",
                        pointHighlightStroke: "rgba(151,187,205,1)",
                        data: [
    <?php
    foreach ($analyseData['yData'] as $value) {
        echo $value . ',';
    }
    ?>
                        ]
                    }
                ]
            };
            function addChart() {

                var ctx1 = document.getElementById("chart-line-2").getContext("2d");
                var myLineChart = new Chart(ctx1).Line(data, {
                    segmentShowStroke: true
                });
            };
            
            addChart();
        </script>
    </div>
<?php } ?>


